
//
//  VIsitorLoginView.swift
//  sinaweibo
//
//  Created by icefs2 on 15/11/9.
//  Copyright © 2015年 icefs2. All rights reserved.
//

import UIKit
//协议方法
protocol VIsitorLoginViewDelegate: NSObjectProtocol {
    func VIsitorLoginViewDidSelected()
    func VIsitorregistedViewDidSelected()
}

class VIsitorLoginView: UIView {

    @IBOutlet weak var messagelable: UILabel!
  
    @IBOutlet weak var smalliconview: UIImageView!
    @IBOutlet weak var iconview: UIImageView!
    //定义代理
    weak var delegate: VIsitorLoginViewDelegate?
    
    func setupinfor(imageName: String, message: String, ishome: Bool = false) {
        iconview.hidden = !ishome
        if ishome {
            startanimation()
            
        iconview.image = UIImage(named: imageName)
        messagelable.text = message
            
        } else {
            smalliconview.image = UIImage(named: imageName)
            stopanimation()
        }
        }
    func startanimation() {
        let anima = CABasicAnimation(keyPath: "transform.rotation")
        anima.toValue = 2 * M_PI
        anima.duration = 20.0
        anima.repeatCount = MAXFLOAT
        smalliconview.layer.addAnimation(anima, forKey: nil)
    }
    func stopanimation() {
        smalliconview.layer.removeAllAnimations()
    }

    @IBAction func registbutton() {
        delegate?.VIsitorregistedViewDidSelected()
        
    }
    @IBAction func loginbutton() {
        delegate?.VIsitorLoginViewDidSelected()
    }
}
